package RPC;

import java.rmi.server.UID;
import java.util.StringTokenizer;

import cs5300.sessionState;

import BasicDataType.CookieType;

public class RequestMessage {
	public String callID;
	public String opeID;
	public sessionState ss;
	//public CookieType cookie;
	//public long discardTime;
	
	
	public RequestMessage(){
		UID uid= new UID();
		callID = uid.toString();
		this.ss = new sessionState();
		opeID = "";
	}
	
	public RequestMessage(String opeID, CookieType cookie, long discardTime){
		this.opeID = opeID;
		this.ss = new sessionState();
		this.ss.cookie = cookie;
		this.ss.discard_time = discardTime;
		UID uid = new UID();
		callID = uid.toString();
	}
	
	public RequestMessage(String str){
		StringTokenizer st = new StringTokenizer(str,"$");
		callID = st.nextToken();
		opeID = st.nextToken();
		//ss.message = st.nextToken();
		this.ss = new sessionState();
		this.ss.cookie = new CookieType(st.nextToken());
		this.ss.discard_time = Long.parseLong(st.nextToken());
	}
	
	public String getString(){
		return callID + "$" + opeID + "$" +  ss.cookie.getString() + "$" + Long.toString(ss.discard_time) + "$";
	}
	
}
